import type { postOrPutType } from "@/constants";
import type { HasId, IResult } from "@/types/common";
import { getAxios, commonAxiosJson, deleteAxios } from "@/utils/request.ts";
/* 管理员用户列表地址 */
const url = "/back/master";
/* 通过id获取管理员用户列表信息 */
export const getUserByIdInfo = <T, D extends HasId>(params: D): Promise<IResult<T>> => {
  return getAxios<T, D>(url + "/" + params.id, params);
};
/* 新增，更新管理员用户列表信息 */
export const commonUserInfoListInfo = <T, D>(params: D, type: postOrPutType): Promise<IResult<T>> => {
  return commonAxiosJson<T, D>(url, params, type);
};
/* 重置用户密码 */
export const updataResetUserPasswordInfo = <T, D>(params: D): Promise<IResult<T>> => {
  return commonAxiosJson<T, D>(url + "/reset-password", params, "PUT");
};
/* 禁用,启用 用户账号 */
export const updataAccountStatusInfo = <T, D>(params: D): Promise<IResult<T>> => {
  return commonAxiosJson<T, D>(url + "/change-status", params, "PUT");
};
/* 删除管理员用户信息 */
export const deleteUserInfo = <T, D>(params: D): Promise<IResult<T>> => {
  return deleteAxios<T, D>(url, params);
};

/* 更新密码 */
export const updateChangepwdInfo = <T, D>(params: D): Promise<IResult<T>> => {
  return commonAxiosJson<T, D>(url + "/change-password", params, "PUT");
};
/* 获取管理员用户个人信息 */
export const getUserInfoInfo = <T>(): Promise<IResult<T>> => {
  return getAxios<T>(url + "/my-info");
};
/* 修改我的信息 */
export const updateMyInfo = <T, D>(params: D): Promise<IResult<T>> => {
  return commonAxiosJson<T, D>(url + "/update-info", params, "PUT");
};
/* 获取客服的推广链接信息 */
export const postMasterUrlLinkInfo = <T, D>(params: D): Promise<IResult<T>> => {
  return commonAxiosJson<T, D>(url + "/get-master-url-link", params, "POST");
};
/* 获取自己的推广链接 */
export const postMyUrlLinkInfo = <T, D>(params: D): Promise<IResult<T>> => {
  return commonAxiosJson<T, D>(url + "/get-my-url-link", params, "POST");
};
